package com.suse.lhw.hms.exersiseserver.controller;

import com.suse.lhw.hms.exersiseserver.constants.ConstStatuMovementModel;
import com.suse.lhw.hms.exersiseserver.constants.ConstStatusPackage;
import com.suse.lhw.hms.exersiseserver.dao.EPackageMapper;
import com.suse.lhw.hms.exersiseserver.domin.*;
import com.suse.lhw.hms.exersiseserver.pojo.out.MovementModelAndUnits;
import com.suse.lhw.hms.exersiseserver.pojo.out.PackageAndModels;
import com.suse.lhw.hms.exersiseserver.service.EMoventmodelService;
import com.suse.lhw.hms.exersiseserver.service.EPackageService;
import com.suse.lhw.hms.exersiseserver.service.EPackageToSingleMmService;
import com.suse.lhw.hms.exersiseserver.service.EUnitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.AnnotationBeanNameGenerator;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ProjectName: health_manage_system
 * @Package: com.suse.lhw.hms.exersiseserver.com.suse.lhw.security.controller
 * @ClassName: ExersiseManagerController
 * @Description: java类作用描述
 * @Author: 李鸿炜
 * @CreateDate: 2020/5/3 14:00
 * @UpdateUser: 更新者
 * @UpdateDate: 2020/5/3 14:00
 * @UpdateRemark: 更新说明
 * @Version: 1.0
 */
@RestController
@RequestMapping("exersiseManager")
public class ExersiseManagerController {
    @Autowired
    EMoventmodelService eMoventmodelService;
    @Autowired
    EUnitService eUnitService;
    @Autowired
    EPackageToSingleMmService ePackageToSingleMmService;
    @Autowired
    EPackageService ePackageService;

    @PostMapping("addADefaultMovementModel")
    public String addADefaultMovenmentModel(EMoventmodel eMoventmodel, @RequestBody List<EUnit> list) {
        /**未测试
         * @Author:Hongwei Li
         * @Description:增加一个默认的动作模型，并一同增加动作单位，动作映射
         * @Date:0:36 2020/5/6
         * @Param:[eMoventmodel, list]
         * @Return:java.lang.String
         **/
        eMoventmodel.setStatus(ConstStatuMovementModel.defaultt);
        if (eMoventmodelService.addAMovenmentModelByStatus(eMoventmodel, list) == 0)
            return "添加失败";
        return "添加成功";
    }
//
//@RequestMapping("deletADefaultMovenmentModel")
//    public String deleteADefaultMovenmetnModel(int mmId){
//    /**
//     * @Author:Hongwei Li
//     * @Description:删除一个默认的运动模型，传入模型的id
//     * @Date:0:51 2020/5/6
//     * @Param:[mmId]
//     * @Return:java.lang.String
//    **/
//    if (eMoventmodelService.deleteByPrimaryKey(mmId)==0)
//        return "删除失败";
//    return "删除成功！";
//}
//
//@PostMapping("updateADefaultMovenmentModel")
//    public String updateADefaultMovenmentModel(EMoventmodel eMoventmodel, @RequestBody List<EUnit> list){
//    /**
//     * @Author:Hongwei Li
//     * @Description:更新一个默认动作模型，包括其单位
//     * @Date:1:26 2020/5/6
//     * @Param:[eMoventmodel, list]
//     * @Return:java.lang.String
//    **/
//    if (eMoventmodelService.updateAMovenmentModelAndUnit(eMoventmodel,list)==0){
//        return "更新失败";
//    }
//    return "更新成功！";
//}
//
//@PostMapping("selectAllDefaultModel")
//    public List<MovementModelAndUnits> selectAllDefaultModel(){
//    /**
//     * @Author:Hongwei Li
//     * @Description:查找所有的默认模型极其单位，并封装成pojo
//     * @Date:1:27 2020/5/6
//     * @Param:[]
//     * @Return:java.util.List<com.suse.lhw.hms.exersiseserver.pojo.out.MovementModelAndUnits>
//    **/
//    return eMoventmodelService.selectAllModelByStatus(ConstStatuMovementModel.defaultt);
//}
//
//@GetMapping("deleteAUnitFromAModel")
//    public String deleteAUnitFromModel(int modelId,int UnitId){
//    /**
//     * @Author:Hongwei Li
//     * @Description:删除某一模块的一个单位，我不知道为什么要穿模型id
//     * @Date:1:34 2020/5/6
//     * @Param:[modelId, UnitId]
//     * @Return:java.lang.String
//    **/
//       if (eUnitService.deleteByPrimaryKey(UnitId)==0)
//           return "没有删除成功！";
//       return "删除成功！";
//}
//
//@PostMapping("addAUnitFromAModel")
//    public String addAUnitFromAModel(int modelId,EUnit eUnit){
//    /**
//     * @Author:Hongwei Li
//     * @Description:为模型增加一个单位，传入模型的id和单位信息，生成映射关系式和单位
//     * @Date:20:32 2020/5/6
//     * @Param:[modelId, eUnit]
//     * @Return:java.lang.String
//    **/
//    if (eUnitService.insertByModelId(modelId,eUnit)==0){
//        return "没有增加成功！";
//    }
//    return "增加成功！";
//}
//
//@PostMapping("addADefaultPackage")
//    public String addADefaultPackage(EPackage ePackage,List<EPackageToSingleMm> list ){
//    /**
//     * @Author:Hongwei Li
//     * @Description:增加一个默认套餐
//     * @Date:21:02 2020/5/6
//     * @Param:[ePackage, list]
//     * @Return:java.lang.String
//    **/
//    if (ePackageService.insertAPackageAndModels(ePackage,list)==0)
//        return "添加失败!  ";
//    return "添加成功！";
//}
//
//@RequestMapping("selectAllDefaultPackage")
//    public List<PackageAndModels> selectAllDefaultPackage(){
//    /**
//     * @Author:Hongwei Li
//     * @Description:搜索所有的默认套餐，输出一个pojo类，每个pojo包含套餐属性和其中model的list
//     * @Date:21:35 2020/5/6
//     * @Param:[]
//     * @Return:java.util.List<com.suse.lhw.hms.exersiseserver.pojo.out.PackageAndModels>
//    **/
//    List<PackageAndModels> result=ePackageService.selectAllPackageByStatus(ConstStatusPackage.defaultt);
//    return  result;
//}
//
//@GetMapping("deleteAPackageById")
//    public String deleteAPackageBYId(int Id){
//    /**
//     * @Author:Hongwei Li
//     * @Description:
//     * @Date:21:42 2020/5/6
//     * @Param:[Id]
//     * @Return:java.lang.String
//    **/
//    if (ePackageService.deleteAllById(Id)==0)
//        return "删除失败！";
//    return "删除成功！";
//}
//@PostMapping("addAModelTOPacakge")
//    public String addAModelToPacage(int packageId, EPackageToSingleMm ePackageToSingleMm){
//    if (ePackageToSingleMmService.insertSelective(ePackageToSingleMm)==0)
//        return "添加成功！";
//    return "添加失败！";
//}
//
//@RequestMapping("deleteAModelToPackge")
//    public String deleteAModelTOpackae(int pakcageId,EPackageToSingleMm ePackageToSingleMm){
//    if(ePackageToSingleMmService.deleteByPrimaryKey(ePackageToSingleMm.getId())==0)
//        return "删除失败！";
//    return "删除成功！";
//}
}
